#! /bin/bash

#     flickrwatcher - Keep track of your friends' flickr photos.
#     Copyright (C) 2008  Joseph G. Echeverria (joey42+flickrwatcher@gmail.com)
# 
#     This program is free software; you can redistribute it and/or modify
#     it under the terms of the GNU General Public License as published by
#     the Free Software Foundation; either version 2 of the License, or
#     (at your option) any later version.
# 
#     This program is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
# 
#     You should have received a copy of the GNU General Public License along
#     with this program; if not, write to the Free Software Foundation, Inc.,
#     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

if [ $# -ne 1 ]; then
	echo "${0}: <release-number>"
	exit -1
fi

RELEASE=${1}
TAG=v${RELEASE}

svn cp trunk tags/${TAG}

mkdir tmp
svn export trunk tmp/flickrwatcher
pushd tmp
pushd flickrwatcher
mv watch.py watch-prepatch.py
cat watch-prepatch.py | sed -e "s/%{VERSION}/${RELEASE}/g" > watch.py 
rm watch-prepatch.py
popd
tar -zcf flickrwatcher-${RELEASE}.tar.gz flickrwatcher
popd
mv tmp/flickrwatcher-${RELEASE}.tar.gz releases
rm -rf tmp
svn add releases/flickrwatcher-${RELEASE}.tar.gz
svn commit -m "Added release v${RELEASE}"
